
using Lockstep.Math;
using Lockstep.Serialization;

namespace Lockstep.Game {
    public partial class PlayerInput : BaseFormater,IComponent {
        public LVector2 inputUV;
        public bool isInputFire;
        public LVector2 inputUV2;
        public bool isInputFire2;
        public override void Serialize(Serializer writer){
            writer.Write(inputUV);
            writer.Write(isInputFire);
            writer.Write(inputUV2);
            writer.Write(isInputFire2);
        }

        public void Reset(){
            isInputFire = false;
            inputUV = LVector2.zero;
            inputUV2 = LVector2.zero;
            isInputFire2 = false;
        }

        public override void Deserialize(Deserializer reader){
            inputUV = reader.ReadLVector2();
            isInputFire = reader.ReadBoolean();
            inputUV2 = reader.ReadLVector2();
            isInputFire2 = reader.ReadBoolean();
        }

        public static PlayerInput Empty = new PlayerInput();
        public override bool Equals(object obj){
            if (ReferenceEquals(this,obj)) return true;
            var other = obj as PlayerInput;
            return Equals(other);
        }

        public bool Equals(PlayerInput other){
            if (other == null) return false;
            if (inputUV != other.inputUV) return false;
            if (isInputFire != other.isInputFire) return false;
            if (inputUV2 != other.inputUV2) return false;
            if (isInputFire2 != other.isInputFire2) return false;
            return true;
        }

        public PlayerInput Clone(){
            var tThis = this;
            return new PlayerInput() {
                inputUV = tThis.inputUV,
                isInputFire = tThis.isInputFire,
                inputUV2 = tThis.inputUV2,
                isInputFire2 = tThis.isInputFire2,
            };
        }
    }
}